import tornado.ioloop
import tornado.web
import tornado.options
import tornado.httpserver

# 1.命令行定义
tornado.options.define('port', default=8888,
                       help="run on the given port", type=int)
tornado.options.define(
    'msb', default=[], help="run on ports", type=str, multiple=True)


class IndexHandler(tornado.web.RequestHandler):
    def get(self):
        self.write('Hello, world')


def make_app():
    return tornado.web.Application([
        (r'/', IndexHandler),
    ])


if __name__ == '__main__':
    # 2.命令行获取
    # tornado.options.parse_command_line()
    tornado.options.parse_config_file('./opt.config')
    print(tornado.options.options.msb)

    app = make_app()
    app.listen(tornado.options.options.port)
    tornado.ioloop.IOLoop.current().start()
